/**
 * Created by sa on 2016/9/21.
 */

  //phantomjs DOMTest.js

//const path = require('path')
var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
page.settings.userAgent = 'YifengAgent';
page.open('http://www.httpuseragent.org', function (status) {
  if (status !== 'success') {
    console.log('Unable to access network');
  } else {

    var savePath = 'D:/work_nodeJS/crawl_youku_nodejs/spider/' + new Date().valueOf() + '.png';
    page.render(savePath);

    var ua = page.evaluate(function () {
      return document.getElementById('myagent').textContent;
    });
    console.log(ua);
  }
  phantom.exit();
});

/*
D:\work_nodeJS\crawl_youku_nodejs\spider>PhantomJS DOMTest.js
The default user agent is Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko)
PhantomJS/2.1.1 Safari/538.1
Your Http User Agent string is: YifengAgent
*/
